<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath%>">
		<title>insert title</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">    
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
			<link rel="stylesheet" type="text/css" href="styles.css">
		-->
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/lib/Hui-iconfont/1.0.7/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/lib/icheck/icheck.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/css/style.css" />
		<script type="text/javascript" src="<%=basePath %>scripts/jquery-1.9.1.js"></script>
		<script type="text/javascript" src="<%=basePath %>scripts/lib/layer/2.1/layer.js"></script>
		<script type="text/javascript">
		$(function(){
			
		});
		window.onload = initMyCource;
		function initMyCource(){
			var teacherNo = '${user.teacherNo}';
			$.ajax({
				url:'<%=basePath%>courceEmployee/json/searchMyCource/'+teacherNo,
				type:'get',
				dataType:'json',
				success:function(data){
					var html="<option value='all'>请选择课程</option>";
					$.each(data,function(i,val){
						html+="<option value='"+val.cource.courceNo+"'>"+val.cource.courceName+"</option>";
					});
					$("#cource").html(html);
					//alert(html);
				},
				error:function(){
					layer.msg("ajax error");
				}
			});
		}
			function addExamPaper(){
				var teacherNo = '${user.teacherNo}';
				var courceNo = $("#cource").val();
				var paperTitle = $("#paper-title").val();
				var paperScore = $("#paper-score").val();
				var paperDuration = $("#paper-duration").val();
				var paperDate = $("#paper-date").val();
				
				if(teacherNo==""){
					layer.msg('登录过期，请先登录系统');
					window.parent.location.href="<%=basePath%>login.html";
				}else if(courceNo=='all' || paperTitle=="" || paperScore==""||paperDuration==""||paperDate==""){
					layer.msg("必填属性不能为空");
				}else{
					var jsonUrl = "<%=basePath%>/exam/addExamPaperInfo";
					var inputData = {
							"examPaperTitle":paperTitle,
							"examPaperScore":paperScore,
							"examPaperDuration":paperDuration,
							"examPaperDate":paperDate,
							"teacher.teacherNo":teacherNo,
							"cource.courceNo":courceNo
					};
					$.ajax({
						url:jsonUrl,
						type:'post',
						dataType:'text',
						data:inputData,
						success:function(data){
							layer.msg('添加成功');
							setTimeout(function(){
								layer.closeAll();
							}, 500);
						},
						error:function(){
							layer.msg('ajax error');
						}
						
					});
				}
				
				//alert(teacherNo+" ---"+courceNo+"----"+paperTitle+"---"+paperScore+"---"+paperDuration+"---"+paperDate);
				/*
				var sclassNo = $("input[name='sclassNo']").val();
				var sclassName = $("input[name='sclassName']").val();
				var gradeNo = $("#grade").val();
				if(sclassNo=="pick" || sclassName=="" ||gradeNo==""){
					layer.msg("必填信息不能为空");
				}else{
					$.ajax({
						url:'<%=basePath%>sclass/addSclass',
						type:'post',
						dataType:'text',
						data:{'grade.gradeNo':gradeNo,'classNo':sclassNo,'className':sclassName},
						success:function(text){
							layer.msg('添加成功');
							setTimeout(function(){
								window.parent.location.reload();
							}, 500);
						}
					});
				}*/
			}
			/*关闭layer窗口*/
			function layer_close(){
				window.parent.layer.closeAll();
			}
		</script>
	</head>
	<body>
		<div class="page-container">
			
			<form class="form form-horizontal">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>课程信息：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<select id="cource" class="select" name="courceNo">
							<option value="pick">请选择课程</option>
						</select>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>试卷名称：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input id="paper-title" type="text" class="input-text" name="sclassNo">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>试卷分值：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input id="paper-score" type="text" class="input-text" name="sclassNo">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>考试时长：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input id="paper-duration" type="text" class="input-text" name="sclassNo">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>考试时间：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input id="paper-date" type="text" class="input-text" name="sclassName">
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
						<button onClick="addExamPaper()" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 添加</button>
						<button onClick="layer_close()" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
					</div>
				</div>
			</form>
		</div>
	</body>
</html>